package com.example.xianji.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.app.Activity;
import android.content.Intent;
import android.view.WindowManager;

import com.example.xianji.R;
import com.example.xianji.constant.Constant;
import com.example.xianji.utils.sp.PreferenceEngine;

/**
 * 启动页
 *
 * @author me
 */
public class LoGoActivity extends Activity {
//    private SharedPreferences sp;
//    private Editor ed;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
        setContentView(R.layout.activity_lo_go);
//        sp = getSharedPreferences("text", MODE_PRIVATE);
//        ed = sp.edit();
        handler.postDelayed(updateThread, 2000);
    }

    Handler handler = new Handler();

    Runnable updateThread = new Runnable() {
        public void run() {
            Intent intent = new Intent();
//            if (sp.getBoolean("xianji_QiDong_flag", false)) {
            if(PreferenceEngine.getInstance().getBoolean(Constant.SP.NAME,
                    Constant.SP.KEY_XIANJI_QIDONG_FLAG,false)){
                intent.setClass(LoGoActivity.this, MainActivity.class);
            } else {
                intent.setClass(LoGoActivity.this, HuanyingActivity.class);
            }
            LoGoActivity.this.startActivity(intent);
            finish();
        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        handler.removeCallbacksAndMessages(null);
        handler.removeCallbacks(updateThread);
    }
}
